(function () {
    "use strict";

    function areBracketsCorrect(inputString)
    {
        var openBrackets = 0;

        for (var i = 0; i < inputString.length && openBrackets >= 0; i++)
        {
            if (inputString[i] === '(')
            {
                openBrackets++;
            }
            else if (inputString[i] === ')')
            {
                openBrackets--;
            }
        }

        return (openBrackets === 0);
    }

    console.log(areBracketsCorrect("((a+b)/5-d)"));
    console.log(areBracketsCorrect(")(a+b))"));
}());